package com.eastedu.controller;

import com.eastedu.model.RequestParameter;
import com.eastedu.superise.handler.HistoricalDataHandler;
import org.springframework.http.HttpEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 试题来源中应用者为空的数据同步更新
 *
 * @author 张志帅
 */
@RestController
@RequestMapping(value = "/api/v1/basic-source/data-sync")
public class ResourceFileDataSyncController {

    private final HistoricalDataHandler historicalDataHandler;

    /**
     * Instantiates a new Resource file data sync controller.
     *
     * @param basicFileHistoricalDataHandler the basic file historical data handler
     */
    public ResourceFileDataSyncController(HistoricalDataHandler basicFileHistoricalDataHandler) {
        this.historicalDataHandler = basicFileHistoricalDataHandler;
    }


    /**
     * Handle http entity.
     *
     * @param parameter the parameter
     * @return the http entity
     */
    @PostMapping("/basic-file")
    public HttpEntity<Boolean> handle(RequestParameter parameter) {
        this.historicalDataHandler.handle(parameter);
        return ResponseEntity.ok(true);
    }

}
